#ifndef _CLOG_H_
#define _CLOG_H_
#include <string>
#include <fstream>
#include <sstream>

namespace cgi{
class CLog
{
public:
	CLog(void);
	~CLog(void);
	void init(const std::string& logPath);

	void log(const std::string& slog);

	template<class T>
	void logKeyValueContainer(T& container, const std::string& sContainerName)
	{
		std::stringstream sLog;
		sLog<<sContainerName;
		for(typename T::const_iterator it = container.begin(); it != container.end(); ++it)
		{
			sLog<<" "<<it->first<<"="<<it->second<<" "<<"\r\n";
		}
		log(sLog.str());
	}

	template<class T>
	void logListContainer(T& container, const std::string& sContainName)
	{
		std::stringstream sLog;
		sLog<<sContainName;
		for(typename T::const_iterator it = container.begin(); it != container.end(); ++it)
		{
			sLog<<" "<<*it<<" ";
		}
		log(sLog.str());
	}
private:
	std::ofstream m_log;
};
}
#endif //_CLOG_H_
